# 导包
from api.goods import GoodsAPI


# 创建测试类
class TestGoodsAPI:
    # 初始化
    theme_id = None
    goods_id = None

    # 前置处理
    def setup(self):
        self.goods_api = GoodsAPI()

    # 获取商品分类
    def test01_get_goods_list(self):
        response = self.goods_api.get_goods_list()
        TestGoodsAPI.theme_id = response.json()[0].get("id")
        print(TestGoodsAPI.theme_id)

    # 获取分类下的商品
    def test02_get_goods_under_list(self):
        response = self.goods_api.get_goods_under_list(TestGoodsAPI.theme_id)
        TestGoodsAPI.goods_id = response.json()[1].get("id")
        print(TestGoodsAPI.goods_id)

    # 获取商品详情
    def test03_get_goods_info(self):
        response = self.goods_api.get_goods_info(TestGoodsAPI.goods_id)
        print(response.json())